package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatUserPublishDto;
import com.usaas.search.service.IPlatUserPublishService;
/**
 * 用户游戏发布Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platUserPublish")
public class AdminPlatUserPublishController extends BaseController {

    @Autowired
    private IPlatUserPublishService platUserPublishService;

    /**
     * 查询用户游戏发布列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:list')")
    @Log(title = "管理端用户游戏发布list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatUserPublishDto platUserPublishDto) {
        List<PlatUserPublishDto> list = platUserPublishService.queryList(platUserPublishDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询用户游戏发布分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:list')")
    @Log(title = "管理端用户游戏发布page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return platUserPublishService.queryPage(platUserPublishDto);
    }


    /**
     * 导出用户游戏发布列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:export')")
    @Log(title = "管理端导出用户游戏发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatUserPublishDto platUserPublishDto) {
        List<PlatUserPublishDto> list = platUserPublishService.queryList(platUserPublishDto);
        ExcelUtil<PlatUserPublishDto> util = new ExcelUtil<>(PlatUserPublishDto.class);
        util.exportExcel(response, list, "用户游戏发布数据");
    }

    /**
     * 获取用户游戏发布详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:query')")
    @Log(title = "管理端获取用户游戏发布详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return AjaxResult.success(platUserPublishService.queryById(platUserPublishDto.getId()));
    }

    /**
     * 新增用户游戏发布
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:add')")
    @Log(title = "管理端新增用户游戏发布", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return toAjax(platUserPublishService.add(platUserPublishDto));
    }

    /**
     * 修改用户游戏发布
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:edit')")
    @Log(title = "管理端修改用户游戏发布", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return toAjax(platUserPublishService.update(platUserPublishDto));
    }
    /**
     * 用户游戏发布审核
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:edit')")
    @Log(title = "管理端用户游戏发布审核", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/check")
    public AjaxResult check(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return platUserPublishService.check(platUserPublishDto);
    }

    /**
     * 删除用户游戏发布
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPublish:remove')")
    @Log(title = "管理端删除用户游戏发布", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatUserPublishDto platUserPublishDto) {
        return toAjax(platUserPublishService.removeBatch(platUserPublishDto.getIds()));
    }

}
